package components
{
	import UIFree.controls.uif_arrowbutton;
	import UIFree.controls.uif_button;
	import UIFree.uif_component;
	
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	public class clt_plButton extends clt_component {
		private var _arrow: uif_arrowbutton;
		private var _title: uif_button;
		public function clt_plButton(parent: uif_component, ax: int=0, ay: int=0, awidth: int=0, 
									 aheight: int=0, caption: String='', onClick: Function=null, 
									 styleClass: Object='buttonB') {
			super(parent, ax, ay, awidth, aheight, styleClass);
			_title.text = caption;
			_title.addEvent(MouseEvent.CLICK, onClick);
		}
		
		public function get arrow(): uif_arrowbutton {
			return _arrow;
		}
		
		public function get title(): uif_button {
			return _title;
		}
		
		override protected function createComponents():void {
			super.createComponents();
			var inner: Rectangle = getInner();
			_arrow = new uif_arrowbutton(this, inner.x, inner.y, inner.height * 0.7, inner.height, 4, 'farrow');
			inner.left += _arrow.width + 5;
			_title = new uif_button(this, inner.x, inner.y, inner.width, inner.height, 'buttonBBase');
		}
		
		override protected function paint(a_styleClass: String, a_method: String = ''): void {
			var rect: Rectangle = getBorder();
			begin2(style);
			var w2: Number = rect.width / 2;
			var h2: Number = rect.height / 2;
			var w6: Number = rect.width / 5;
			this.graphics.moveTo(rect.x, rect.y + h2);
			this.graphics.lineTo(rect.x + h2, rect.y);
			this.graphics.lineTo(rect.x + rect.width - h2, rect.y);
			this.graphics.curveTo(rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + h2);
			this.graphics.curveTo(rect.x + rect.width, rect.y + rect.height, rect.x + rect.width - h2, rect.y + rect.height);
			this.graphics.lineTo(rect.x + h2, rect.y + rect.height);
			this.graphics.lineTo(rect.x, rect.y + h2);
			this.graphics.endFill();
		}
	}
}